home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Arashi 1.1 / Game Source / Arashi Script < prev    next >
Text File  |  1993-07-08  |  6KB  |  225 lines

  1. /*
  2.     Copyright:
  3.     
  4.         Arashi 1.1
  5.         Copyright ©1993, Project STORM Team
  6.  
  7.         This file is freely distributable,
  8.         but the parser and compiler for
  9.         it may only be used along with the
  10.         Arashi game. For permission to use
  11.         the compiler or parts of it for other
  12.         things, please request permission from
  13.  
  14.                         Juri Munkki
  15.             internet:    jmunkki@hut.fi
  16.             applelink:    sf0010
  17. */
  18.  
  19. FileScript=1    //    Reading from a file. (In case you are interested.)
  20.  
  21. level 1        //    Starting from level 1, use the following rules:
  22.  
  23.     AllowPracticeRestart    =    Level % 2
  24.     AllowArcadeRestart    =    Level % 2
  25.  
  26.     FlipperProb        =    1 + SubLevel / 15
  27.     FlipperCount    =    4 + SubLevel / 3 + Level / 8 - PulsarCount / 3 max 16
  28.     FlipperRot        =    (4 + Level/1.5) ^ 0.7 max 12
  29.     FlipperSpeed    =     (1.0 + Level / 12) ^ 0.3
  30.  
  31.     SpikerProb        =    (0.5 + SubLevel / 32) * (SubLevel > 3)
  32.     SpikeStart        =    DEPTH - ((SubLevel - 2) * DEPTH / 15 min 0)
  33.     SpikeTop        =    DEPTH * 0.1
  34.     SpikerSpeed        =    1 + Level / 40 max 2.5
  35.     
  36.     EndTimer        =    3.2 / Level max 1.5
  37.     BoredomCount    =    2 + Level / 10 max 7
  38.     BoredProb        =    1.0 + Level / 32
  39.  
  40.     FlipTankCount    =    (SubLevel - 1) ^ 0.7 - FuseTankCount / 2
  41.     FlipTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  42.     FlipTankProb    =    0.3 + SubLevel / 20
  43.     
  44. level 11
  45.     FuseCount        =    2
  46.     FuseProb        =    0.5 + SubLevel / 15
  47.     FuseWarpP        =    Level / 100 max 0.5
  48.     FusePlayerPlus    =    Level / 40 max 0.9
  49.     
  50. level 16
  51.     SpikeStart        =    DEPTH - ((SubLevel - 2) * DEPTH / 15 min 0)
  52.     SpikerProb        =    (0.5 + SubLevel / 32) * (SubLevel > 1)
  53.     
  54. level 17
  55.     FuseCount        =    0
  56.     PulsarProb        =    0.7 + SubLevel / 20
  57.     PulsarCount        =    4 + SubLevel / 5 + Level / 10 max 12
  58.     PulsarRot        =    (4 + Level/2) ^ 0.6 max 11
  59.     PulsarSpeed        =    (Level / 20) ^ 0.3
  60.     PulsarTime        =    20 - Level / 20 min 5
  61.  
  62. level 19
  63.     FuseCount        =    (Level / 3) ^ 0.7 max 6
  64.     AllowArcadeRestart    =    (Level % 2) < 1
  65.  
  66. level 30
  67.     AllowArcadeRestart    =    (Level % 2)
  68.     
  69. level 33
  70.     FuseTankCount    =    SubLevel ^ 0.3 + 2 - PulsarTankCount / 2
  71.     FuseTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  72.     FuseTankProb    =    0.3 + SubLevel / 20
  73.  
  74. level 35
  75.     AllowArcadeRestart    =    (Level % 4) < 1
  76.     
  77. level 40
  78.     PulsarTankCount    =    SubLevel ^ 0.3 + 2
  79.     PulsarTankSpeed    =    (1.0 + Level / 12) ^ 0.4
  80.     PulsarTankProb    =    0.3 + SubLevel / 20
  81.  
  82. level 47
  83.     AllowArcadeRestart    =    (Level % 2)
  84.  
  85. level 51
  86.     AllowArcadeRestart    =    (Level % 4) < 1
  87.     
  88. level 63
  89.     AllowArcadeRestart    =    (Level % 2)
  90.     
  91. level 67
  92.     AllowArcadeRestart    =    ((Level-65) % 8) < 1
  93.     
  94. level 82
  95.     AllowArcadeRestart    =    0
  96.     
  97.     
  98. level 32000    //    We should never need to go past this point
  99.  
  100. /* Finally, some instructions on how to modify this file:
  101.  
  102.  
  103. Here's a short grammar of the language. It should be pretty obvious for anyone
  104. with a little background in grammars.
  105.  
  106. Items in braces can be repeated 
  107.  
  108. statement    ->    level n
  109.                 variable = compare
  110.  
  111. compare        ->    minmax { = minmax }
  112.                 minmax { > minmax }
  113.                 minmax { < minmax }
  114.  
  115. minmax        ->    expr { min expr }
  116.                 expr { max expr }
  117.  
  118. expr        ->    term { + term }
  119.                 term { - term }
  120.  
  121. term        ->    power { * power }
  122.                 power { / power }
  123.                 power { % power }
  124.  
  125. power        ->    factor { ^ factor }
  126.  
  127. factor        ->    (compare)
  128.                 -factor
  129.                 factor
  130.                 +factor
  131.                 variable
  132.                 constant
  133.                 function1 factor
  134.                 function0
  135.  
  136.  
  137. functions with no parameters: (function0)
  138.  
  139.         random
  140.  
  141. functions with one parameter: (function1)
  142.  
  143.         |         (abs)
  144.         sin
  145.         cos
  146.         int
  147.         round
  148.  
  149. keywords:
  150.         level
  151.  
  152.  
  153.     *********************
  154.     *    How it works    *
  155.     *********************
  156.  
  157. The idea is that you define variables and that new lines in
  158. the script will replace old lines. For a certain level, only
  159. those definitions that appear before the next greater 'level'
  160. statement will be used to define that level.
  161.  
  162. Order of evaluation is unspecified and there are no guarantees
  163. that variables will have reasonable values unless they are
  164. initialized. If a circular reference is encountered, an old
  165. value of a looped variable will be used to get out of the loop.
  166.  
  167. For instance:
  168.  
  169.     a = b
  170.     b = a + 1
  171.     
  172. If we evaluate a, we usually get 1 on the first round. This is
  173. because most variables are initialized to 0. If we execute it
  174. again, we get 2 etc. If, instead we evaluate b, we get 1, but
  175. the value of a will be 0. I hope this is confusing enough so
  176. that you will avoid circular references. Let's just say that
  177. they are not very useful, but they do not cause problems.
  178.  
  179. The order of evaluation is on a "need to know basis". I guess
  180. it's called intelligent recalculation in spreadsheet programs.
  181. Let's look at it with a short example:
  182.  
  183.     a = 10
  184.     b = a + 20
  185.     c = 30
  186.     d = b + a
  187.     
  188. If we then evaluate d, the system will try to evaluate b, notice
  189. that b requires a to be defined, so it evaluates a and then b. It
  190. then sees a again, but notices that it has been evaluated already
  191. and uses the old value. c does not get evaluated at all.
  192.  
  193. Let's look at something more complicated:
  194.  
  195.     level 1
  196.     
  197.         b = a
  198.         a = 1
  199.         a = 2
  200.  
  201.     level 16
  202.     
  203.         a = 3
  204.  
  205. From levels 1 to 15, b will evaluate to 2, because that's the last
  206. definition of a. From level 16, the value of b will be 3.
  207.  
  208. The definition a = 1 is not used at all, although it does get compiled
  209. before the next line replaces it.
  210.  
  211. To actually define a game level, you have to define variables that of
  212. interest to the game. These variables are introduced in a prescript
  213. resource. Feel free to peek at that resource to see what variables are
  214. available [during development, the prescript might be empty and the
  215. Arashi Script file could contain everything].
  216.  
  217. Variables that are prefixed with an 'i' are by convention internal
  218. variables. In the next part of the prescript, these variables are
  219. connected with variables that you should use. For instance, we have
  220. iFlipperCount and FlipperCount. You should use FlipperCount even though
  221. iFlipperCount is really the variable that the game wants. This convention
  222. allows us to scale or limit the values that can be set. For instance,
  223. we should probably limit FlipperCount to a minimum of 0.
  224.  
  225. */